package com.itzhihao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itzhihao.entity.Cart;
import com.itzhihao.entity.vo.CartVo;
import com.ruoyi.common.core.page.PageDomain;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartMapper extends BaseMapper<Cart> {

    @Select("select c.shopcart_id as id,c.product_id as prodId,c.product_num as num,p.cate,p.prod_desc as prodDesc,p.name as prodName,p.mainimage as prodMainImage,c.price,s.name as storeName,s.mainimage as storeMainImage," +
            "p.subimages as prodSubImages,p.price as prodPrice,p.stock as prodStock,p.discount as prodDiscount,p.store_id as storeId,p.status as prodStatus from glgl_product as p, glgl_shopcart as c, " +
            "glgl_store as s where c.user_id = #{userId} and p.store_id = s.store_id and p.prod_id = c.product_id and c.is_deleted = 0 limit #{pageDomain.pageStart},#{pageDomain.pageSize}")
    List<CartVo> selectCartList(@Param(value = "pageDomain") PageDomain pageDomain, @Param(value = "userId") Long userId);
}
